package com.surendra.vendingmachine.unittest;
import static org.junit.Assert.*;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;



public class VendingMachineItemTest {
VendingMachineItem item1, item2;
	@Before
	public void setUp() throws Exception {
		item1= new VendingMachineItem ("crackers",1.50);
		item2= new VendingMachineItem("Pepsi",1.25);
	}

	@After
	public void tearDown() throws Exception {
		item1=null;
		item2=null;
	}

	@Test
	/**
	 * check whether item1 is instance of VendingMachineItem
	 * to see whether constructor constructs the vending machine
	 */
	public void testVendingMachineItem() {
		assertTrue(item1 instanceof VendingMachineItem);
		assertTrue(item2 instanceof VendingMachineItem);
	}
	

	@Test
	/**
	 * checks the name constructed by constructor is
	 * actual given name
	 */
	public void testGetName() {
		assertEquals("crackers",item1.getName());
		assertEquals("Pepsi",item2.getName());
	}
	@Test
	/**
	 * checks to make sure it fails if the given name 
	 * is not actual
	 */
	public void testGetWrongName(){
		assertNotSame("Mt. Dew", item2.getName());
	}
			

	@Test
	/**
	 * tests whether price set is the one actual price
	 * that we set
	 */
	public void testGetPrice() {
		assertEquals(1.25, item2.getPrice(),0.001);
	}
	@Test
	/**
	 * tests whether item has the wrong price
	 */
	public void testWrongPrice(){
		assertNotSame(5.00,item2.getPrice());
	}

}
